var Sponsors = (function(){
    var idx = 0;
    var interval = null;

    var rotate = function(){
        var sponsors = $('article.sponsors #logos a');
        var current = $('article.sponsors #logos a.show')[0];

        if(current){
            $(current).removeClass('show');
        }

        $(sponsors[idx]).addClass('show');
        if(idx++ == sponsors.length-1){
            idx = 0;
        }
    };

    var start = function(delay){
        interval = setInterval(rotate, delay);
        rotate();
    };

    var stop = function(){
        clearInterval(interval);
    };

    return {
        start : function(delay){
            start(delay);
        },
        stop : stop
    }
})();

/*

 var sponsorIdx = 0;
    function rotateSponsors() {
        var sponsors = document.querySelectorAll("article.sponsors #logos a");
        var current = document.querySelectorAll("article.sponsors #logos a.show")[0];

        if (current) {
            current.classList.remove("show");
        }

        sponsors[sponsorIdx].classList.add("show");

        if (sponsorIdx++ == sponsors.length - 1) {
            sponsorIdx = 0;
        }

    }

    setInterval(rotateSponsors, 7000);
    rotateSponsors();*/
